package com.api.gbhg.liubing.action;

import com.api.gbhg.lbj.dao.GeneralProjectDao;
import com.api.gbhg.liuwenbo.action.OfficeSupplies;
import com.api.gbhg.liubing.dao.NotForContractWorkersDao;
import com.api.gbhg.zengping.dao.PropertyManagementCostDao;
import com.api.gbhg.zengping.utils.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import weaver.conn.RecordSet;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;

import java.util.HashMap;
import java.util.Map;

/**
 * @author : liubing
 * @date :  2021/1/4 15:24
 * 不占编合同工劳务费入库
 */
public class ServiceFeeWarehousing implements Action {
    private static final Logger log = LoggerFactory.getLogger("gbhg");
    @Override
    public String execute(RequestInfo requestInfo) {
        log.info("-----------------不占编合同工劳务费入库------------------------");
        String requestid = requestInfo.getRequestid();//请求id
        NotForContractWorkersDao dao=new NotForContractWorkersDao();
        RecordSet rs = dao.getServiceFeeWarehousing(requestid);//获取数据
        PropertyManagementCostDao p=new PropertyManagementCostDao();
        Map<String, String> map = new HashMap<>();
        RecordSet recordSet = GeneralProjectDao.deleteWorkflowByid(requestid);
        recordSet.next();
        boolean b= true;
        while (rs.next()){
            map.put("requestId",requestInfo.getRequestid());
            map.put("sbdw", rs.getStringNoTrim("sbdw"));
            map.put("xmmc", rs.getStringNoTrim("xmmin"));
            map.put("lcbj", rs.getStringNoTrim("lcbj"));
            map.put("lcjlid", rs.getStringNoTrim("lcjlsqjlid"));
            map.put("bmzcjjfl", rs.getStringNoTrim("bmyszcjjfl"));
            map.put("zfjjfl", rs.getStringNoTrim("dyzfjjfl"));
            map.put("nd", rs.getStringNoTrim("ysnd"));
            map.put("ze", rs.getStringNoTrim("hjwy"));
            String syed = "0.00";
            if (rs.getStringNoTrim("hjwy").equals("")) {
                map.put("ze","0.00");
                syed = "0.00";
            }else {
                syed=rs.getStringNoTrim("hjwy");
            }
            map.put("syed", syed);
            map.put("dj", "0.00");
            map.put("modedatamodifier",rs.getStringNoTrim("jbr"));
            map.put("gkdw",rs.getStringNoTrim("gkdw"));
            map.put("sydw",rs.getStringNoTrim("sydw"));
            map.put("modedatamodifydatetime", DateUtil.getNowDate());
            boolean resV = p.insertBudgeLines(map);
            if (!resV){
                b=false;
            }
        }
        if (!b) {
            requestInfo.getRequestManager().setMessagecontent("不占编合同工劳务费入库失败");
            requestInfo.getRequestManager().setMessageid("");
            log.info("同步流程不占编合同工劳务费数据到入库表失败！");
            return FAILURE_AND_CONTINUE;
        } else {
            return SUCCESS;
        }
    }

}
